<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>

<sql:query var="query" dataSource="jdbc/dbo_MicrosoftSQLServer">
    select * from Turnos
    inner join horarios on turnos.id_turno=horarios.id_turno
    where situacao_turno='A' and turnos.id_turno=?
    order by hora_inicio
   <sql:param value="${param.id_turno}"/>
</sql:query>
<c:choose>
    <c:when test="${!empty query.rows}">
        <label class="lbInput">Turno<em>*</em></label>
        <select  name="id_horario">
            <option value="">Selecione um horário</option>
            <c:forEach var="row" items="${query.rows}">
                <option value="${row.id_horario}">${row.desc_turno} (${row.hora_inicio} - ${row.hora_fim})</option>
            </c:forEach>
        </select>
    </c:when>
    <c:otherwise>
        <p style="font-size: 12pt; color: red">Nenhum horário foi encontrado.</p>
    </c:otherwise>
</c:choose>